home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
163_02
/
smallcv2.doc
< prev
next >
Wrap
Text File
|
1991-01-05
|
23KB
|
464 lines
.* My thanks to Dick Dievendorff for fixing up this file to format with
.* GML. Now, if someone could do the same with SCLIB DOC . . .
:gdoc.
:frontm.
:titlep.
:title.Small-c Version 2.0
:title.for the IBM Personal Computer
:title.Release 1.01
:date.
:author.Daniel R. Hicks
:address.
:aline.
:aline.RCH38DB(HICKS)
:eaddress.
:etitlep.
:preface.
:p.Portions of Small-c code Copyright 1982 by J. E. Hendrix.
:p.Converted to the IBM Personal Computer by D. R. Hicks.
:p.This document was developed entirely by D. R. Hicks, and is
:hp1.not:ehp1. copyrighted.
:body.
:h1.Why Small-c?
:p.
Why bother with a limited version of the C programming language when
complete versions of the language are available? The main reason is
price. The cheapest "full" C implementations run about $75, and
prices increase from there up to the $500 range. Small-c is free, and
this means that many users who would not want to pay for a full
implementation will have access to this one. Other users who may not
be sure that they want pay for a full C implementation can use this
one to determine if they like the language.
:p.
Another reason for the existence of Small-c is control: You get all
of the source for Small-c, and you can, if you wish, maintain or
modify it yourself. You can also change the I/O support package to
suit your needs, and you can even port the compiler to a different
processor if you wish (this version is converted from an 8080
version).
:h1.What can Small-c do?
:p.
Small-c takes a source file, consisting of C-subset statements, and
creates an assembler source file. This assembler source file can be
processed by either the IBM Small Assembler or the IBM Macro Assembler
to produce an IBM/Intel format OBJ file. The OBJ file can, in turn,
be combined with other OBJ files and LIB files via the DOS LINK
function to produce an executable EXE module. An I/O & utility
function library is provided for this purpose, implementing an
environment which quite closely mimics the UNIX environment.
:p.
This version of Small-c can be executed on an IBM PC with 128K of
storage, one single-sided diskette drive, and running IBM DOS 1.1 or
2.0. In all likelihood, the compiler will execute on a 96K system,
but this has never been tried. Since at least 96K is needed to run
either of the assemblers, there is little merit in executing in less
than 96K. Although dual diskette drives are necessary for large
compilations (where the assembler source can occupy most of one
diskette), they are useful but not essential otherwise. Where a hard
file is available, this may be used in place of diskettes. The
compiler runs equally well on DOS 1.1 and DOS 2.0, although it does
not utilize the increased function of DOS 2.0. Release 1.01 has added
up to 2 dimensional arrays of all supported data types (D. Lang 12/90)
:p.
Programs created with the compiler (and suitably assembled and linked)
can be executed on any IBM DOS system with sufficient storage.
Normally, the programs must be linked with the associated Small-c
library which, in addition to providing I/O support, sets up the
operating environment. However, a reasonably adept programmer should
be able to link Small-c procedures with procedures from other
compilers, if necessary coding assembler "glue" via the the Small-c
"#asm" statement.
:p.
Although it has never (to my knowledge) been attempted, there is no
known reason why this version of Small-c (and the programs it
compiles) should not execute equally well on any suitably configured
IBM PC-compatible MS DOS system.
:h1.What WON'T it do?
:p.
Small-c was originated by Ron Cain, and was originally published in
Dr. Dobb's Journal, number 45. The original intent was to provide
users of small microprocessor systems with a compact yet powerful
systems programming language, one which could be both used and
maintained on a small system. For this reason, many of the features
of full C implementations were omitted, resulting in a restricted but
usable language. Small-c Version 2.0 was developed by J. E. Hendrix
and published in Dr. Dobb's Journal, numbers 74 & 75. This version,
slightly larger to account for the tendency toward larger systems, has
fewer restrictions and is considerably more powerful. Nonetheless, it
has significant restrictions relative to full C implementations. The
following are the principle restrictions:
:ol.
:li.Structures and unions are not supported.
:li.Up to 2 dimensions arrays supported in Release 1.01
:li.Floating point is not supported.
:li."Long" integers are not supported.
:li.Only functions returning integers are supported.
:li.Pointers to pointers, arrays of pointers, and several of the other
exotic forms of declarations are not supported.
:eol.
:h1.Running Small-c
:p.
The compiler may be invoked with the parameters specified on the
command line, with prompting for the parameters, or a combination of
the two. To invoke the compiler with prompting, type:
:sl.
:li.CC
:esl.
:pc.The compiler will display the prompt:
:sl.
:li.Input file [CON.C]:
:esl.
:pc.Type in the name of the file containing your C program. A
filename extension of "C" is assumed. If you enter no filename, input
will be accepted from the keyboard.
:p.The compiler will then display the prompt:
:sl.
:li.Output file [CON.ASM]:
:esl.
:p.
Type in the file name of the file to contain the assembler source. A
filename identical to the source file name and an extension of "ASM"
is assumed.
:p.
The compiler will then display the prompt:
:sl.
:li.Listing file [NUL.LST]:
:esl.
:p.
Normally, the listing file is either suppressed (by routing to the NUL
device) or is routed to the printer (by specifying "prn", for
example). If no filename is specified, NUL is assumed.
:pc.
The compiler then asks the following yes/no questions:
:sl.
:li.Interleave C source?
:li.Monitor function headers?
:li.Sound alarm on errors?
:li.Pause on errors?
:esl.
:p.
"Interleave C source" means to place the C source statements into the
assembler source as comments. This is very useful if the assembler
source is to be examined or modified after compilation, but it
increases the size of the assembler source file (by slightly more than
the size of the C source file).
:p.
"Monitor function headers" means to display each function header (and
include statement) as it is processed. This is useful both for
monitoring the progress of the compilation and for interpreting the
context of error messages from the compiler. This question is not
asked (and function headers and include statements are not displayed)
if output is being routed to the display screen.
:p.
"Sound alarm on errors" means to sound the PC's "bell" (beeper)
whenever an error message is displayed (also, when the compilation
ends). This is useful for long compilations where one might wish to
leave the computer unattended but be alerted when attention was
needed.
:p.
"Pause on errors" means to stop after displaying each error message
and wait for an "ENTER" before proceeding. This prevents the error
message from being scrolled off the screen before it can be examined.
:p.
After these questions have been answered, the compilation will begin.
C source statements will be read from the input file and written to
the output file. Function headers and include statements will be
displayed if selected. When the compilation is finished, the
following message is displayed (where n is a number):
:sl.
:li.There were n errors in this compilation
:esl.
:p.
If the number of errors is zero (or if you are willing to accept
whatever the errors are that have occurred), you may process the
produced assembler source with ASM (IBM Small Assembler) or MASM (IBM
Macro Assembler). Once the program has been successfully compiled and
assembled, it should be linked, using the DOS LINK program, with the
CC.LIB library supplied, thereby producing the executable EXE file.
:p.
When parameters are specified via the DOS command line, the file names
must be entered in order -- source file, assembler file, listi